package crawler;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class TableAdapter {
	  private String url = "jdbc:mysql://localhost:3306/document";
	  private String driver = "com.mysql.jdbc.Driver";
	  private String userName = "root"; 
	  private String password = "admin";
	  private Connection conn=null;
	  private MessageBox ErrMessage;
	  private PreparedStatement statement;
	  
	  public Connection getConn() {
		return conn;
	}
	  public void setConn(Connection conn) {
		this.conn = conn;
	}
	  public String getPassword() {
		return password;
	}
	  public String getDriver() {
		return driver;
	}
	  public MessageBox getErrMessage() {
		return ErrMessage;
	}
	  public PreparedStatement getStatement() {
		return statement;
	}
	  
	  public String getUrl() {
		return url;
	}
	  public String getUserName() {
		return userName;
	}
	  
	  
	  public void MySQLConnect()
	  {
		  try {
			  Class.forName(driver).newInstance();
			  conn = DriverManager.getConnection(url,userName,password);
			  ErrMessage = new MessageBox("Connected to the database");
			  } catch (Exception e) {
				  ErrMessage = new MessageBox(e.toString());
			  }
	  }
	  
	  public void MySQLDisconnect(){
		  try {
		  if(!conn.isClosed())
			conn.close();
		} catch (SQLException e) {
			ErrMessage = new MessageBox(e.toString());
		}
		  ErrMessage = new MessageBox("Disconnected from database");
	  }
	  
	  
}
